package com.stylefeng.guns.modular.system.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.stylefeng.guns.modular.small.dto.ConsumerCommentDTO;
import com.stylefeng.guns.modular.system.dao.ConsumerCommentMapper;
import com.stylefeng.guns.modular.system.model.ConsumerComment;
import com.stylefeng.guns.modular.system.service.IConsumerCommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 用户评论 服务实现类
 * </p>
 *
 * @author stylefeng
 * @since 2019-09-09
 */
@Service
@Slf4j
public class ConsumerCommentServiceImpl extends ServiceImpl<ConsumerCommentMapper, ConsumerComment> implements IConsumerCommentService {

    @Resource
    private ConsumerCommentMapper consumerCommentMapper;

    @Override
    public PageInfo<ConsumerComment> searchList(Integer artificerId, Integer pageCount, Integer currentCount) {
        if (artificerId == null) throw new RuntimeException("技师id不能为空!");
        PageHelper.startPage(currentCount, pageCount);
        PageInfo<ConsumerComment> pageInfo = null;
        try {
            List<ConsumerComment> list = consumerCommentMapper.searchConsumerCommentPages(artificerId);
            pageInfo = new PageInfo<ConsumerComment>(list);
        } catch (Exception e) {
            e.printStackTrace();
            log.info("技师列表查询异常：{}", e.getMessage());
        }
        return pageInfo;
    }


    @Override
    public PageInfo<ConsumerCommentDTO> searchDtoList(Integer artificerId, Integer pageCount, Integer currentCount) {
        if (artificerId == null) throw new RuntimeException("技师id不能为空!");
        PageHelper.startPage(currentCount, pageCount);
        PageInfo<ConsumerCommentDTO> pageInfo = null;
        try {
            List<ConsumerCommentDTO> list = consumerCommentMapper.searchConsumerCommentDtoPages(artificerId);
            pageInfo = new PageInfo<ConsumerCommentDTO>(list);
        } catch (Exception e) {
            e.printStackTrace();
            log.info("技师列表查询异常：{}", e.getMessage());
        }
        return pageInfo;
    }
}
